package io.jnet.client.client.impl;

import java.nio.channels.AsynchronousChannelGroup;
import java.nio.channels.AsynchronousSocketChannel;
import java.util.concurrent.ExecutorService;
import io.jnet.common.api.AioListener;
import io.jnet.common.api.ChannelContext;
import io.jnet.common.build.ChannelContextBuilder;
import io.jnet.common.build.ChannelContextConfig;
import io.jnet.common.channelcontext.ThreadAttachChannelContext;

public class ThreadAttachClient extends AbstractClient
{
    
    public ThreadAttachClient(ExecutorService businessExecutorService, ChannelContextBuilder clientChannelContextBuilder, AsynchronousChannelGroup channelGroup, String serverIp, int port, AioListener aioListener)
    {
        super(businessExecutorService, clientChannelContextBuilder, channelGroup, serverIp, port, aioListener);
    }
    
    @Override
    protected ChannelContext parse(ChannelContextConfig config, AsynchronousSocketChannel socketChannel, AioListener listener)
    {
        ChannelContext serverChannelContext = new ThreadAttachChannelContext(//
                businessExecutorService, //
                config.getBufStorage(), //
                config.getMaxMerge(), //
                listener, //
                config.getInProcessors(), //
                config.getOutProcessors(), //
                socketChannel, //
                config.getFrameDecodec());
        return serverChannelContext;
    }
    
}
